home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Zins1a.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-09
|
3KB
|
105 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Zins1a.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TZins::TZins (void) : TObject ()
{
}
//---------------------------------------------------------------------------
void __fastcall TZins::SetKapital (String Text)
{
try {Kapital = StrToFloat (Text);}
catch (...){Kapital = 0;}
}
//---------------------------------------------------------------------------
void __fastcall TZins::SetProzent (String Text)
{
try {Prozent = StrToFloat (Text);}
catch (...){Prozent = 0;}
}
//---------------------------------------------------------------------------
void __fastcall TZins::SetZinsen (String Text)
{
try {Zinsen = StrToFloat (Text);}
catch (...){Zinsen = 0;}
}
//---------------------------------------------------------------------------
String __fastcall TZins::CalcKapital (void)
{
Kapital = Zinsen * 100 / Prozent;
return (String(FloatToStrF(Kapital,ffNumber,8,2)));
}
//---------------------------------------------------------------------------
String __fastcall TZins::CalcProzent (void)
{
Prozent = Zinsen * 100 / Kapital;
return (String(FloatToStrF(Prozent,ffNumber,8,2)));
}
//---------------------------------------------------------------------------
String __fastcall TZins::CalcZinsen (void)
{
Zinsen = Kapital * Prozent / 100;
return (String(FloatToStrF(Zinsen,ffNumber,8,2)));
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SetZero (void)
{
Zins1->Kapital = 0;
Zins1->Prozent = 0;
Zins1->Zinsen = 0;
Edit1->Text = "0";
Edit2->Text = "0";
Edit3->Text = "0";
Modus = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Zins1 = new TZins ();
SetZero ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
SetZero ();
Label1->Caption = "Gib fⁿr die gesuchte Gr÷▀e eine Null ein!";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Zins1->SetKapital (Edit1->Text);
if (Edit1->Text == "0") Modus++;
Zins1->SetProzent (Edit2->Text);
if (Edit2->Text == "0") Modus+=10;
Zins1->SetZinsen (Edit3->Text);
if (Edit3->Text == "0") Modus+=100;
switch (Modus)
{
case 1:
Edit1->Text = Zins1->CalcKapital();
break;
case 10:
Edit2->Text = Zins1->CalcProzent ();
break;
case 100:
Edit3->Text = Zins1->CalcZinsen ();
break;
default:
Label1->Caption = "Das sind zu viele Nullen!";
}
Modus = 0;
}
//---------------------------------------------------------------------------